<?php
class CV_Validate_Callback extends CV_Validate_Abstract {
	protected $_args;
	protected $_callback;
	/**
	 * @param callback $callback
	 */
	public function __construct( $callback ){
		$args = func_get_args();
		$this->_callback = array_shift( $args );
		$this->_args = $args;
	}
	public function _isValid( $value ){
		$func_args = func_get_args();
		$args = array_merge(
			$func_args,
			$this->_args
		);
		if( call_user_func_array($this->_callback,$args) ){
			return true;
		}
		$this->_messages = array( "'%value%' does not validate against %callback%" );
		return false;
	}
}